<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2016/9/28
 * Time: 23:50
 */header('Content-type:text/html;charset=utf-8');
?>
<html>
<head>
    <style>
        table{border-collapse:collapse}
        td{border:1px solid black;padding:5px}
    </style>
</head>
<body>
<?php
const DISCOUNT =0.7;
$fruit1 = '香蕉';
$fruit2 = '苹果';
$fruit3 = '橘子';

$fruit1_num='2';
$fruit2_num='1';
$fruit3_num='3';

$fruit1_price='5.5';
$fruit2_price='6.0';
$fruit3_price='3.0';

$fruit1_total=$fruit1_price*$fruit1_num;
$fruit2_total=$fruit2_price*$fruit2_num;
$fruit3_total=$fruit3_price*$fruit3_num;

$total=($fruit1_total+$fruit2_total+$fruit3_total)*DISCOUNT;



$str="<table>";
$str.="<tr><td>商品名称</td><td>购买数量（斤）</td><td>商品价格（元）</td></tr>";
$str.="<tr><td>$fruit1</td><td>$fruit1_num</td><td>$fruit1_price</td></tr>";
$str.="<tr><td>$fruit2</td><td>$fruit2_num</td><td>$fruit2_price</td></tr>";
$str.="<tr><td>$fruit3</td><td>$fruit3_num</td><td>$fruit1_price</td></tr>";
$str.="<tr><td colspan='3'>商品折扣：<span> ".DISCOUNT."</span></td></tr>";
$str.="<tr><td colspan='3'>折后购买商品总价：{$total}元</td></tr>";
echo $str;
?>
</body>
</html>


